<template>
  <!-- 我的申请 -->
  <el-container>
    <el-main class="nopadding">
      <scTable
        ref="table"
        :apiObj="apiObj"
        row-key="id"
        stripe
        @filterType="filterType"
        @row-dblclick="handleRowClick"
      >
        <el-table-column label="ID" prop="id" width="80"></el-table-column>
        <el-table-column
          label="主题"
          prop="title"
          min-width="150"
        ></el-table-column>
        <el-table-column label="类型" prop="examineType" width="200">
          <template #default="scope">
            <!-- 0表单审核 1申请修改 -->
            <p>{{ scope.row.examineType == 0 ? "表单审核" : "申请修改" }}</p>
          </template>
        </el-table-column>
        <el-table-column label="摘要" prop="detail" min-width="200">
          <template #default="scope">
            <item-detail
              ref="itemDetail"
              :data="scope.row.detail"
            ></item-detail>
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="totalStatus" width="300">
          <template #default="scope">
            <!-- 0未审核 1审核通过 2审核拒绝  -->
            <el-tag type="warning" v-if="scope.row.totalStatus == 0">
              待审核
            </el-tag>
            <el-tag type="success" v-if="scope.row.totalStatus == 1">
              通 过
            </el-tag>
            <el-tag type="danger" v-if="scope.row.totalStatus == 2">
              未通过
            </el-tag>
            <el-tag type="warning" v-if="scope.row.totalStatus == 3">
              审核中
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="申请时间"
          prop="createTime"
          width="300"
        ></el-table-column>
        <el-table-column
          label="申请人"
          prop="applicantName"
          width="300"
        ></el-table-column>
      </scTable>
    </el-main>
  </el-container>
</template>
<script>
import itemDetail from '../components/itemDetail.vue'
import { queryTypeByDic } from '@/utils/getData'
import { handleClick, initTableRow } from '@/utils/handleRouter'
export default {
  name: 'myApply',
  data () {
    return {
      apiObj: this.$API.home.getMyApplyList,
      produceStatus: [],//生产单状态
      deliverStatus: [],//送货状态
      followType: [],//跟进类型
      searchValue: {
        search: null
      }
    }
  },
  components: {
    itemDetail
  },
  mounted () {
    this.getType()
  },
  methods: {
    async getType () {
      this.produceStatus = await queryTypeByDic('produceStatus')
      this.deliverStatus = await queryTypeByDic('deliverStatus')
      this.followType = await queryTypeByDic('followType')
    },
    filterType (data) {
      initTableRow(data)

    },
    handleRowClick (row) {
      console.log(row)
      handleClick(row.streamType, row.detail.id)
    },

  }
}
</script>

<style>
</style>